package cas.ihep.hep.util;

import java.util.ArrayList;
import java.util.List;

public class GlobalSet {
    double DecayFactor[]=new double[3];
    String pareqL[]=new String[30];
    String pareqR[]=new String[30];
    //deconstructor
    String _interference,_birthfactor;
    int LStype; // 0: bare Breit-Wigner, 1: only inclusion of  momentum dependent width, 2: inclusion p factor and varying width
    int FormFactor,AmplitudeType;

    String DIYchicj2VV;
    boolean UserDIY;
    boolean CAT;
    boolean LLhel;

    double xmass,xwidth,xresolution,sqrts,nominalM,nominalW;
    List<Double> son0_spinden=new ArrayList<>(),
            son1_spinden=new ArrayList<>(),
            son2_spinden=new ArrayList<>(),
            son3_spinden=new ArrayList<>(),
            son4_spinden=new ArrayList<>();
    List<Double> VGLB=new ArrayList<>(),
            VGLBmax=new ArrayList<>(),
            Vimp=new ArrayList<>();
    boolean debug;
    double barrierR;
    List<Integer> intopt=new ArrayList<>();
    String _commonDecay,_PipiSwavePhase;
    List<String> sonspin=new ArrayList<>();
    double bgwt;//background weight
    List<Integer> mulData=new ArrayList<>(),
            mulMc=new ArrayList<>(),
            mulBg=new ArrayList<>();
    List<List<String> > VMulPar=new ArrayList<>();

    public String euqapar(String name){
        String thename="";
        for(int i=0;i<30;i++){
            if(pareqL[i].isEmpty()){
                break;
            }else if(name.equals(pareqL[i])){
                thename=pareqR[i];
            }
        }
        return thename;
    }

    public int getSampleIndex(List<Integer> setsample,int ievt){
        int last=setsample.get(0);
        if(ievt<last){
            return 0;
        }
        int len=setsample.size();
        for(int i=1;i<len;i++){
            int cur=last+setsample.get(i);
            if(last<=ievt && ievt<cur){
                return i;
            }
            last=cur;
        }
        throw new RuntimeException("No samples found");
    }

    public int getPar(List<String> theparname,String name){
        String thename=euqapar(name);
        if(!thename.isEmpty()){
            name=thename;
        }
        int len=theparname.size();
        for(int i=0;i<len;i++){
            if(name.equals(theparname.get(i))){
                return i;
            }
        }
        throw new RuntimeException("No parameters found");
    }
}
